package com.ywqf_api.service.impl;

import com.ywqf_api.dao.BoundHouseDao;
import com.ywqf_api.entity.House;
import com.ywqf_api.entity.ParkingData;
import com.ywqf_api.service.BoundHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2018/4/8 0008.
 */
@Service
public class BoundHouseServiceImpl implements BoundHouseService{
    @Autowired
    private BoundHouseDao boundHouseDao;

    @Override
    public int findIsNull(Integer communityId, String houseNum, String ownerName, String ownerTel) {
         House house = boundHouseDao.findIsNull(communityId,houseNum,ownerName,ownerTel);
         if(house == null){
             return 0;
         }else{
             Integer houseId = house.getHouseId();
             return houseId;
         }
    }

    @Override
    public int updateCustomerHouseId(Integer houseId,Integer customerId) {
        int update = boundHouseDao.updateCustomerHouseId(houseId,customerId);
        if(update > 0){
            return 1;
        }else{
            return 0;
        }
    }

    @Override
    public int updateCustomer(Integer customerId, String url, String name, Integer gender) {
        int update = boundHouseDao.updateCustomer(customerId,url,name,gender);
        if(update > 0){
            return 1;
        }else{
            return 0;
        }
    }

    @Override
    public List<ParkingData> findHouseCars(Integer houseId) {
        List<ParkingData> list = boundHouseDao.findHouseCars(houseId);
        if(list.size() > 0){
            return list;
        }else{
            return null;
        }
    }
}
